<%@ page language="java" pageEncoding="utf-8"%>
<%@taglib prefix="s" uri="/struts-tags"%>
<%@taglib prefix="m" uri="/cutm_tags"%>
<html>
<head>
<title>添加用户</title>
<script type="text/javascript">
$(document).ready(function() {
	$("#uerForm").vaildAjax(function(data){
		if(data.charAt(0) =='a'){
			$('input[name="user.id"]').val(data.substring(1));
			BaseJs.alert('添加用户成功');
		}
		if(data.charAt(0) =='u'){
			BaseJs.alert('修改用户信息成功');
		}
	});
	$("#repwdform").vaildAjax(function(data){
		if(data!=''){
			BaseJs.alert(data,'error');
		}else{
			BaseJs.alert('修改密码成功,下次登录生效');
			$('#repaitpwd').slideUp("slow");
		}
	});
	$("#foucusForm").vaildAjax(function(data){
		if(data!=''){
			BaseJs.alert(data,'error');
		}else{
			BaseJs.alert('修改密码成功,下次登录生效');
			$('#repaitpwd').slideUp("slow");
		}
	});
	<s:if test='user==null'>
		cheak();
		$('#lock').hide();
		$('#focusRw').hide();
	</s:if><s:else>
		$('input[name="user.nickName"]').attr('readonly','true');
		$('#pwdtr').hide();
	</s:else>

	$('#addUser').click(function(){
		$('#uerForm').resetForm();
		cheak();
	});
	$('#lock').toggle(function(){
		$('#repaitpwd').slideDown();
	},function(){
		$('#repaitpwd').slideUp();
	});
	$('#focusRw').toggle(function(){
		$('#foucspwd').slideDown();
	},function(){
		$('#foucspwd').slideUp();
	});
});
function cheak(){
	$('input[name=user.man]').radio('true');
}
</script>
</head>
<body>
<h2 class="title"><span>添加用户</span><m:permiss permiss="SYS_ADMIN"><m:imgA img="officer" id="focusRw" msg="强制修改密码" /></m:permiss><m:imgA img="lock" id="lock" msg="修改密码" /><m:permiss permiss="SYS_ADMIN"><m:imgA img="addUser" action="user/EditUser!view" msg="添加用户" /></m:permiss></h2>
<div id="repaitpwd" style="display: none;">
<h2 class="title">修改密码</h2>
<s:form id="repwdform" action="user/EditUser!repwd">
	<s:hidden name="user.id" />
	<table class="form">
		<tr>
			<th width="10%">原密码*</th>
			<td width="23%"><s:password name="oripwd" cssClass="rule[required]" maxlength="32" /></td>
			<th width="10%">新密码*</th>
			<td width="23%"><s:password name="user.passwd" id="rnwpd" cssClass="rule[required]" maxlength="32" /></td>
			<th width="10%">再次输入*</th>
			<td width="24%"><s:password name="renewpwd" cssClass="rule[required,confirm[rnwpd]]" maxlength="32" /></td>
		</tr>
	</table>
	<div class="btnGroup"><s:submit value="确认修改" /></div>
</s:form></div>
<m:permiss permiss="SYS_ADMIN">
	<div id="foucspwd" style="display: none;">
	<h2 class="title">强制修改密码</h2>
	<s:form id="foucusForm" action="user/EditUser!focuspwd">
		<s:hidden name="user.id" />
		<table class="form">
			<tr>
				<th width="20%">新密码*</th>
				<td width="30%"><s:password name="user.passwd" id="rnwpd1" cssClass="rule[required]" maxlength="32" /></td>
				<th width="20%">再次输入*</th>
				<td width="30%"><s:password name="renewpwd" cssClass="rule[required,confirm[rnwpd1]]" maxlength="32" /></td>
			</tr>
		</table>
		<div class="btnGroup"><s:submit value="确认修改" /></div>
	</s:form></div>
</m:permiss>
<s:form id="uerForm" action="user/EditUser">
	<s:hidden name="user.id" />
	<table class="form">
		<tr>
			<th width="10%">用户登录名</th>
			<td width="40%"><s:textfield name="user.nickName" cssClass="rule[required,noSpecChar]]" maxlength="100" /></td>
			<th width="10%">用户状态</th>
			<td width="40%">
				<s:if test="status"><s:radio list="#{true:'可用',false:'禁用'}" name="user.enable" cssClass="rule[required]" />
				</s:if><s:else>
					<s:if test="user.enable">可用</s:if><s:else>禁用</s:else>
					<s:hidden name="user.enable" />
				</s:else>
			</td>
		</tr>
		<s:if test="user==null">
			<tr>
				<th>用户密码</th>
				<td><s:password name="user.passwd" cssClass="rule[required]" maxlength="32" id="pwd" /></td>
				<th>用户密码</th>
				<td><s:password name="same" cssClass="rule[required,confirm[pwd]]" /></td>
			</tr>
		</s:if>
		<s:else>
			<s:hidden name="user.passwd" />
		</s:else>
		<tr>
			<th>个人文件夹地址</th>
			<td><s:textfield name="user.folder" maxlength="200" /></td>
			<th>备用地址</th>
			<td><s:textfield name="user.folderbak" maxlength="200" /></td>
		</tr>
		<tr>
			<th>用户姓名</th>
			<td><s:textfield name="user.name" cssClass="rule[required]" maxlength="50" /></td>
			<th>用户性别</th>
			<td><s:radio cssClass="rule[required] " list="#{true:'男',false:'女'}" name="user.man" /></td>
		</tr>
		<tr>
			<th>用户联系方式</th>
			<td><s:textfield name="user.link" maxlength="50" /></td>
			<th>家庭住址</th>
			<td><s:textfield name="user.address" maxlength="250" /></td>
		</tr>
		<tr>
			<th>学历</th>
			<td><m:select enumType="degree.type" name="user.degree" /></td>
			<th>政治面貌</th>
			<td><m:select enumType="zzmm.type" name="user.zzmm" /></td>
		</tr>
		<tr>
			<th>电子邮件</th>
			<td><s:textfield name="user.email" maxlength="50" /></td>
			<th>电话</th>
			<td><s:textfield name="user.telel" maxlength="30" /></td>
		</tr>
		<tr>
			<th>身份证号码</th>
			<td><s:textfield name="user.idcard" maxlength="18" /></td>
			<th>所属部门</th>
			<td><m:select enumType="dept.type" name="user.dept" cssClass="rule[required]" /></td>
		</tr>
		<tr>
			<th>角色</th>
			<td colspan="3"><s:property value="rolelist" escape="false" /></td>
		</tr>
	</table>
	<div class="btnGroup"><input type="submit" value="保存"></div>
</s:form>
</body>
</html>